package com.neuedu.controller;

import java.util.List;
import java.util.Scanner;

import com.neuedu.bean.User;

public class UserController {
	private static  Scanner scan=new Scanner(System.in);
	/**
	 * 添加数据到list对象中
	 * @param list
	 */
	public static void input(List<User> list) {
		int n=0;
		System.out.println("要添加的的人数：（请输入）");
		n=scan.nextInt();
		//输入数据，使用for
		for(int i=0;i<n;i++) {
			System.out.println("请输入第"+(i+1)+"个人的信息：");
			//每次user重新new一个对象
			User user1=new User();
			System.out.println("请输入编号");
			user1.setUserid(scan.nextInt());
			System.out.println("请输入用户名");
			user1.setUsername(scan.next());
			System.out.println("请输入密码");
			user1.setUserpwd(scan.next());
			System.out.println("请输入年龄");
			user1.setAge(scan.nextInt());
			
			list.add(user1);
		}
		
		
	}
	
	
	/**
	 * 输出
	 */
	public static void output(List<User> list) {
		System.out.println("编号\t用户名\t密码\t年龄");
		for(User user:list) {
			System.out.println(user.getUserid()+"\t"+user.getUsername()+"\t"+user.getUserpwd()+"\t"+user.getAge());
		}
	}
	

}
